/**
 * Copyright (C), 2015-2024, XXX有限公司
 * FileName: MathTest
 * Author:   Administrator
 * Date:     2024/3/16 17:33
 * Description:
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */

import org.junit.jupiter.api.Test;

import java.math.BigDecimal;

/**
 * 〈一句话功能简述〉<br> 
 * 〈〉
 *
 * @author Administrator
 * @create 2024/3/16
 * @since 1.0.0
 */
public class MathTest {

    @Test
    public void test1() {
        BigDecimal b1 = new BigDecimal(0.01);
        BigDecimal b2 = new BigDecimal("0.01");
        BigDecimal b3 = BigDecimal.valueOf(0.01);

        System.out.println("b1 = " + b1);
        System.out.println("b2 = " + b2);
        System.out.println("b3 = " + b3);
    }

    @Test
    public void test2(){
        BigDecimal b1 = new BigDecimal("0.09");
        BigDecimal b2 = new BigDecimal("0.01");
        System.out.println("add = " + b1.add(b2));
        System.out.println("sub = " + b1.subtract(b2));
        System.out.println("mul = " + b1.multiply(b2));
        System.out.println("div = " + b1.divide(b2));
    }


    @Test
    public void test3(){
        BigDecimal b1 = new BigDecimal("0.09");
        BigDecimal b2 = new BigDecimal("0.01");
        System.out.println(b1.equals(b2));
        System.out.println(b1.compareTo(b2));
    }


}